using System;
using System.Collections.Generic;
using System.Text;

namespace GoogleNet
{
    /// <summary>
    /// Defines an image associated with an Icon style or overlay. 
    /// Icon has the same child elements as Link. The required href child element 
    /// defines the location of the image to be used as the overlay or as the icon 
    /// for the placemark. 
    /// This location can either be on a local file system or a remote web server. 
    /// </summary>
    public class KmlIcon : KmlLink, IKmlGenerator
    {
        private string tagName = "Icon";

        /// <summary>
        /// Name of the KML tag for this specific element.
        /// </summary>
        /// <value></value>
        /// <returns></returns>
        public override string TagName
        {
            get
            {
                return this.tagName;
            }
        }

        #region IKmlGenerator Members

        /// <summary>
        /// Generates the KML for this element including its child elements.
        /// </summary>
        /// <param name="writer">The XML writer that will be used to generate the KML.</param>
        public new void GenerateKml(System.Xml.XmlTextWriter writer)
        {
            writer.WriteStartElement(tagName);

            if (base.Href.ToString() != string.Empty)
                writer.WriteElementString("href", base.Href.ToString());

            if (base.RefreshMode != KmlRefreshModes.onChange)
                writer.WriteElementString("refreshMode", base.RefreshMode.ToString());

            if (base.RefreshInterval != 4)
                writer.WriteElementString("refreshInterval", base.RefreshInterval.ToString());

            if (base.ViewRefreshMode != KmlViewRefreshModes.never)
                writer.WriteElementString("viewRefreshMode", base.ViewRefreshMode.ToString());

            if (base.ViewRefreshTime != 4)
                writer.WriteElementString("viewRefreshTime", base.ViewRefreshTime.ToString());

            if (base.ViewBoundScale != 1)
                writer.WriteElementString("viewBoundScale", base.ViewBoundScale.ToString());

            if (base.ViewFormat.ToString() != string.Empty)
                writer.WriteElementString("viewFormat", base.ViewFormat.ToString());

            if (base.HttpQuery.ToString() != string.Empty)
                writer.WriteElementString("httpQuery", base.HttpQuery.ToString());

            writer.WriteFullEndElement();
        }

        #endregion
    }
}
